home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_libpcap.idb / usr / freeware / catman / p_man / cat3 / pcap.Z / pcap
Text File  |  2002-04-08  |  28KB  |  531 lines

  1. PCAP(3)                              PCAP(3)
  2.  
  3.  
  4.  
  5. NNAAMMEE
  6.        pcap - Packet Capture library
  7.  
  8. SSYYNNOOPPSSIISS
  9.        ##iinncclluuddee    <<ppccaapp..hh>>
  10.  
  11.        cchhaarr eerrrrbbuuff[[PPCCAAPP__EERRRRBBUUFF__SSIIZZEE]];;
  12.  
  13.        ppccaapp__tt **ppccaapp__ooppeenn__lliivvee((cchhaarr **ddeevviiccee,, iinntt    ssnnaapplleenn,,
  14.            iinntt pprroommiisscc,, iinntt    ttoo__mmss,, cchhaarr **eerrrrbbuuff))
  15.        ppccaapp__tt **ppccaapp__ooppeenn__ddeeaadd((iinntt lliinnkkttyyppee,, iinntt    ssnnaapplleenn))
  16.        ppccaapp__tt **ppccaapp__ooppeenn__oofffflliinnee((cchhaarr **ffnnaammee,, cchhaarr **eerrrrbbuuff))
  17.        ppccaapp__dduummppeerr__tt **ppccaapp__dduummpp__ooppeenn((ppccaapp__tt **pp,,    cchhaarr **ffnnaammee))
  18.  
  19.        iinntt ppccaapp__sseettnnoonnbblloocckk((ppccaapp__tt **pp,, iinntt nnoonnbblloocckk,, cchhaarr **eerrrrbbuuff));;
  20.        iinntt ppccaapp__ggeettnnoonnbblloocckk((ppccaapp__tt **pp,, cchhaarr **eerrrrbbuuff));;
  21.  
  22.        iinntt ppccaapp__ffiinnddaallllddeevvss((ppccaapp__iiff__tt ****aallllddeevvsspp,, cchhaarr **eerrrrbbuuff))
  23.        vvooiidd ppccaapp__ffrreeeeaallllddeevvss((ppccaapp__iiff__tt **))
  24.        cchhaarr **ppccaapp__llooookkuuppddeevv((cchhaarr **eerrrrbbuuff))
  25.        iinntt ppccaapp__llooookkuuppnneett((cchhaarr **ddeevviiccee,,    bbppff__uu__iinntt3322 **nneettpp,,
  26.            bbppff__uu__iinntt3322 **mmaasskkpp,, cchhaarr    **eerrrrbbuuff))
  27.  
  28.        iinntt ppccaapp__ddiissppaattcchh((ppccaapp__tt    **pp,, iinntt    ccnntt,,
  29.            ppccaapp__hhaannddlleerr ccaallllbbaacckk,, uu__cchhaarr **uusseerr))
  30.        iinntt ppccaapp__lloooopp((ppccaapp__tt **pp,,    iinntt ccnntt,,
  31.            ppccaapp__hhaannddlleerr ccaallllbbaacckk,, uu__cchhaarr **uusseerr))
  32.        vvooiidd ppccaapp__dduummpp((uu__cchhaarr **uusseerr,, ssttrruucctt ppccaapp__ppkktthhddrr **hh,,
  33.            uu__cchhaarr **sspp))
  34.  
  35.        iinntt ppccaapp__ccoommppiillee((ppccaapp__tt **pp,, ssttrruucctt bbppff__pprrooggrraamm **ffpp,,
  36.            cchhaarr **ssttrr,, iinntt ooppttiimmiizzee,,    bbppff__uu__iinntt3322 nneettmmaasskk))
  37.        iinntt ppccaapp__sseettffiilltteerr((ppccaapp__tt **pp,, ssttrruucctt bbppff__pprrooggrraamm    **ffpp))
  38.        vvooiidd ppccaapp__ffrreeeeccooddee((ssttrruucctt bbppff__pprrooggrraamm **));;
  39.  
  40.        uu__cchhaarr **ppccaapp__nneexxtt((ppccaapp__tt    **pp,, ssttrruucctt ppccaapp__ppkktthhddrr **hh))
  41.  
  42.        iinntt ppccaapp__ddaattaalliinnkk((ppccaapp__tt    **pp))
  43.        iinntt ppccaapp__ssnnaappsshhoott((ppccaapp__tt    **pp))
  44.        iinntt ppccaapp__iiss__sswwaappppeedd((ppccaapp__tt **pp))
  45.        iinntt ppccaapp__mmaajjoorr__vveerrssiioonn((ppccaapp__tt **pp))
  46.        iinntt ppccaapp__mmiinnoorr__vveerrssiioonn((ppccaapp__tt **pp))
  47.        iinntt ppccaapp__ssttaattss((ppccaapp__tt **pp,, ssttrruucctt    ppccaapp__ssttaatt **ppss))
  48.        FFIILLEE **ppccaapp__ffiillee((ppccaapp__tt **pp))
  49.        iinntt ppccaapp__ffiilleennoo((ppccaapp__tt **pp))
  50.        vvooiidd ppccaapp__ppeerrrroorr((ppccaapp__tt **pp,, cchhaarr    **pprreeffiixx))
  51.        cchhaarr **ppccaapp__ggeetteerrrr((ppccaapp__tt    **pp))
  52.        cchhaarr **ppccaapp__ssttrreerrrroorr((iinntt eerrrroorr))
  53.  
  54.        vvooiidd ppccaapp__cclloossee((ppccaapp__tt **pp))
  55.        vvooiidd ppccaapp__dduummpp__cclloossee((ppccaapp__dduummppeerr__tt **pp))
  56.  
  57. DDEESSCCRRIIPPTTIIOONN
  58.        The Packet Capture library provides a high level    interface
  59.        to packet capture systems. All  packets    on  the     network,
  60.        even  those  destined  for  other  hosts,  are  accessible
  61.        through this mechanism.
  62.  
  63.  
  64. RROOUUTTIINNEESS
  65.        NOTE:  _e_r_r_b_u_f   in   ppccaapp__ooppeenn__lliivvee(()),    ppccaapp__ooppeenn__ddeeaadd(()),
  66.        ppccaapp__ooppeenn__oofffflliinnee(()),              ppccaapp__sseettnnoonnbblloocckk(()),
  67.        ppccaapp__ggeettnnoonnbblloocckk(()), ppccaapp__ffiinnddaallllddeevvss(()),    ppccaapp__llooookkuuppddeevv(()),
  68.        and  ppccaapp__llooookkuuppnneett(())  is  assumed  to  be able to hold at
  69.        least PPCCAAPP__EERRRRBBUUFF__SSIIZZEE chars.
  70.  
  71.        ppccaapp__ooppeenn__lliivvee(())     is  used  to  obtain  a  packet  capture
  72.        descriptor to look at packets on    the network.  _d_e_v_i_c_e is    a
  73.        string that specifies the network device    to open; on Linux
  74.        systems    with  2.2  or later kernels, a _d_e_v_i_c_e argument of
  75.        "any" or    NNUULLLL can be used  to  capture  packets    from  all
  76.        interfaces.  _s_n_a_p_l_e_n specifies the maximum number of bytes
  77.        to capture.  _p_r_o_m_i_s_c specifies if the interface is  to  be
  78.        put into    promiscuous mode.  (Note that even if this param
  79.        eter is false, the interface could well be in  promiscuous
  80.        mode  for  some other reason.)  For now,    this doesn't work
  81.        on the "any" device; if an argument of "any"  or     NULL  is
  82.        supplied,  the  _p_r_o_m_i_s_c    flag is    ignored.  _t_o___m_s    specifies
  83.        the read    timeout    in milliseconds.   The    read  timeout  is
  84.        used to arrange that the    read not necessarily return imme
  85.        diately when a packet is    seen, but that it wait    for  some
  86.        amount of time to allow more packets to arrive and to read
  87.        multiple    packets    from the OS kernel in one operation.  Not
  88.        all  platforms  support    a read timeout;    on platforms that
  89.        don't, the read timeout is ignored.   _e_r_r_b_u_f  is     used  to
  90.        return  error  or  warning  text.  It will be set to error
  91.        text when ppccaapp__ooppeenn__lliivvee(()) fails    and returns NNUULLLL.  _e_r_r_b_u_f
  92.        may also    be set to warning text when ppccaapp__ooppeenn__lliivvee(()) suc
  93.        ceds; to    detect this case the caller should store a  zero-
  94.        length  string  in  _e_r_r_b_u_f before calling ppccaapp__ooppeenn__lliivvee(())
  95.        and display the warning to the user if _e_r_r_b_u_f is    no longer
  96.        a zero-length string.
  97.  
  98.        ppccaapp__ooppeenn__ddeeaadd(())     is  used for creating a ppccaapp__tt    structure
  99.        to use when calling the other functions in libpcap.  It is
  100.        typically  used    when just using    libpcap    for compiling BPF
  101.        code.
  102.  
  103.        ppccaapp__ooppeenn__oofffflliinnee(()) is called to    open a    ``savefile''  for
  104.        reading.      _f_n_a_m_e     specifies  the    name of    the file to open.
  105.        The file    has the    same format as those used  by  ttccppdduummpp((11))
  106.        and  ttccppsslliiccee((11)).   The    name  "-" in a synonym for ssttddiinn.
  107.        _e_r_r_b_u_f is used to return    error text and is only    set  when
  108.        ppccaapp__ooppeenn__oofffflliinnee(()) fails and returns NNUULLLL.
  109.  
  110.        ppccaapp__dduummpp__ooppeenn(())     is  called  to     open  a ``savefile'' for
  111.        writing.    The name "-" in    a synonym for  ssttddoouutt.     NNUULLLL  is
  112.        returned     on  failure.    _p is a _p_c_a_p struct as returned by
  113.        ppccaapp__ooppeenn__oofffflliinnee(()) or ppccaapp__ooppeenn__lliivvee(()).     _f_n_a_m_e    specifies
  114.        the  name  of  the  file     to  open.   If    NNUULLLL is    returned,
  115.        ppccaapp__ggeetteerrrr(()) can be used to get    the error text.
  116.  
  117.        ppccaapp__sseettnnoonnbblloocckk(()) puts a capture descriptor, opened  with
  118.        ppccaapp__ooppeenn__lliivvee(()),  into ``non-blocking''    mode, or takes it
  119.        out of ``non-blocking'' mode,  depending     on  whether  the
  120.        _n_o_n_b_l_o_c_k     argument  is non-zero or zero.     It has    no effect
  121.        on ``savefiles''.  If there is an error,     -1  is     returned
  122.        and _e_r_r_b_u_f is filled in with an appropriate error message;
  123.        otherwise, 0 is returned.  In  ``non-blocking''    mode,  an
  124.        attempt to read from the    capture    descriptor with    ppccaapp__ddiiss
  125.        ppaattcchh(()) will, if    no packets are currently available to  be
  126.        read,  return  0     immediately rather than blocking waiting
  127.        for packets to arrive.  ppccaapp__lloooopp(()) and    ppccaapp__nneexxtt(())  will
  128.        not work    in ``non-blocking'' mode.
  129.  
  130.        ppccaapp__ggeettnnoonnbblloocckk(())  returns  the     current ``non-blocking''
  131.        state of    the capture descriptor;    it always  returns  0  on
  132.        ``savefiles''.    If  there is an    error, -1 is returned and
  133.        _e_r_r_b_u_f is filled    in with    an appropriate error message.
  134.  
  135.        ppccaapp__ffiinnddaallllddeevvss(()) constructs a list  of     network  devices
  136.        that  can  be  opened  with  ppccaapp__ooppeenn__lliivvee(()).  (Note that
  137.        there may be network devices that cannot     be  opened  with
  138.        ppccaapp__ooppeenn__lliivvee(())      by   the   process  calling  ppccaapp__ffiinndd
  139.        aallllddeevvss(()), because, for example,    that  process  might  not
  140.        have  sufficient    privileges to open them    for capturing; if
  141.        so, those devices will not appear on the    list.)     _a_l_l_d_e_v_s_p
  142.        is  set    to  point  to the first    element    of the list; each
  143.        element of the list is of type ppccaapp__iiff__tt, and has the fol
  144.        lowing members:
  145.  
  146.           nneexxtt   if     not  NNUULLLL, a pointer to the next element
  147.              in    the list; NNUULLLL for the    last  element  of
  148.              the list
  149.  
  150.           nnaammee   a    pointer    to a string giving a name for the
  151.              device to pass to ppccaapp__ooppeenn__lliivvee(())
  152.  
  153.           ddeessccrriippttiioonn
  154.              if    not NNUULLLL, a pointer to a string    giving    a
  155.              human-readable description    of the device
  156.  
  157.           aaddddrreesssseess
  158.              a    pointer    to the first element of    a list of
  159.              addresses for the interface
  160.  
  161.           ffllaaggss  interface flags:
  162.  
  163.              PPCCAAPP__IIFF__LLOOOOPPBBAACCKK
  164.                  set if the    interface is  a     loopback
  165.                  interface
  166.  
  167.        Each   element  of  the    list  of  addresses  is     of  type
  168.        ppccaapp__aaddddrr__tt, and    has the    following members:
  169.  
  170.           nneexxtt   if    not NNUULLLL, a pointer to the  next  element
  171.              in     the  list;  NNUULLLL for the last element of
  172.              the list
  173.  
  174.           aaddddrr   a pointer to a ssttrruucctt ssoocckkaaddddrr containing an
  175.              address
  176.  
  177.           nneettmmaasskk
  178.              if     not NNUULLLL, a pointer to    a ssttrruucctt ssoocckkaaddddrr
  179.              that contains the netmask    corresponding  to
  180.              the address pointed to by aaddddrr
  181.  
  182.           bbrrooaaddaaddddrr
  183.              if     not NNUULLLL, a pointer to    a ssttrruucctt ssoocckkaaddddrr
  184.              that contains the broadcast  address  corre
  185.              sponding  to the address pointed to by aaddddrr;
  186.              may be null if the    interface doesn't support
  187.              broadcasts
  188.  
  189.           ddssttaaddddrr
  190.              if     not NNUULLLL, a pointer to    a ssttrruucctt ssoocckkaaddddrr
  191.              that contains the destination address corre
  192.              sponding  to the address pointed to by aaddddrr;
  193.              may be null if the    interface isn't    a  point-
  194.              to-point interface
  195.  
  196.        ppccaapp__ffrreeeeaallllddeevvss(())  is  used  to     free a    list allocated by
  197.        ppccaapp__ffiinnddaallllddeevvss(()).
  198.  
  199.        ppccaapp__llooookkuuppddeevv(())    returns    a pointer  to  a  network  device
  200.        suitable     for  use  with    ppccaapp__ooppeenn__lliivvee(()) and ppccaapp__llooookkuupp
  201.        nneett(()).  If there    is an error, NNUULLLL is returned and  _e_r_r_b_u_f
  202.        is filled in with an appropriate    error message.
  203.  
  204.        ppccaapp__llooookkuuppnneett(())     is  used to determine the network number
  205.        and mask    associated with    the network device ddeevviiccee.   Both
  206.        _n_e_t_p  and  _m_a_s_k_p    are _b_p_f___u___i_n_t_3_2    pointers.  A return of -1
  207.        indicates an error in which case    _e_r_r_b_u_f is filled in  with
  208.        an appropriate error message.
  209.  
  210.        ppccaapp__ddiissppaattcchh(())    is  used  to collect and process packets.
  211.        _c_n_t specifies the maximum number     of  packets  to  process
  212.        before  returning.   This  is  not  a minimum number; when
  213.        reading a live capture, only one    bufferful of  packets  is
  214.        read  at     a  time,  so  fewer than _c_n_t packets may be pro
  215.        cessed. A _c_n_t of    -1 processes all the packets received  in
  216.        one buffer when reading a live capture, or all the packets
  217.        in the file when    reading    a ``savefile''.     _c_a_l_l_b_a_c_k  speci
  218.        fies a routine to be called with    three arguments: a _u___c_h_a_r
  219.        pointer which is    passed in from ppccaapp__ddiissppaattcchh(()),    a pointer
  220.        to  the    _p_c_a_p___p_k_t_h_d_r struct (which precede the actual net
  221.        work headers and    data), and a _u___c_h_a_r pointer to the packet
  222.        data.
  223.  
  224.        The  number of packets read is returned.     0 is returned if
  225.        no packets were read from a live    capture    (if, for example,
  226.        they  were  discarded  because they didn't pass the packet
  227.        filter, or if, on platforms that    support     a  read  timeout
  228.        that starts before any packets arrive, the timeout expires
  229.        before any packets arrive, or if    the file  descriptor  for
  230.        the  capture device is in non-blocking mode and no packets
  231.        were available to be read)  or  if  no  more  packets  are
  232.        available  in  a    ``savefile.'' A    return of -1 indicates an
  233.        error in    which case ppccaapp__ppeerrrroorr(()) or ppccaapp__ggeetteerrrr(()) may  be
  234.        used to display the error text.
  235.  
  236.        NNOOTTEE:  when  reading  a live capture, ppccaapp__ddiissppaattcchh(()) will
  237.        not necessarily return when the read times  out;     on  some
  238.        platforms, the read timeout isn't supported, and, on other
  239.        platforms, the timer doesn't  start  until  at  least  one
  240.        packet  arrives.      This means that the read timeout should
  241.        NNOOTT be used in, for example, an    interactive  application,
  242.        to  allow  the  packet  capture    loop to    ``poll'' for user
  243.        input periodically, as there's no guarantee that    ppccaapp__ddiiss
  244.        ppaattcchh(()) will return after the timeout expires.
  245.  
  246.        ppccaapp__lloooopp(())  is similar to ppccaapp__ddiissppaattcchh(()) except it keeps
  247.        reading packets until _c_n_t  packets  are    processed  or  an
  248.        error  occurs.  It does nnoott return when live read timeouts
  249.        occur.  Rather, specifying  a  non-zero    read  timeout  to
  250.        ppccaapp__ooppeenn__lliivvee(())     and  then calling ppccaapp__ddiissppaattcchh(()) allows
  251.        the reception and processing of any  packets  that  arrive
  252.        when   the   timeout   occurs.     A  negative  _c_n_t  causes
  253.        ppccaapp__lloooopp(()) to loop forever (or at least     until    an  error
  254.        occurs).
  255.  
  256.        ppccaapp__nneexxtt(())  reads  the    next packet (by    calling    ppccaapp__ddiiss
  257.        ppaattcchh(()) with a _c_n_t of 1)    and returns a _u___c_h_a_r  pointer  to
  258.        the data    in that    packet.     (The _p_c_a_p___p_k_t_h_d_r struct for that
  259.        packet is not supplied.)
  260.  
  261.        ppccaapp__dduummpp(()) outputs a packet to    the  ``savefile''  opened
  262.        with  ppccaapp__dduummpp__ooppeenn(()).     Note  that its    calling    arguments
  263.        are suitable for    use with ppccaapp__ddiissppaattcchh(()) or  ppccaapp__lloooopp(()).
  264.        If   called  directly,  the  _u_s_e_r  parameter  is     of  type
  265.        _p_c_a_p___d_u_m_p_e_r___t as    returned by ppccaapp__dduummpp__ooppeenn(()).
  266.  
  267.        ppccaapp__ccoommppiillee(()) is used to compile the string  _s_t_r  into    a
  268.        filter  program.      _p_r_o_g_r_a_m  is  a pointer to a _b_p_f___p_r_o_g_r_a_m
  269.        struct and is filled in by ppccaapp__ccoommppiillee(()).  _o_p_t_i_m_i_z_e  con
  270.        trols  whether  optimization on the resulting code is per
  271.        formed.    _n_e_t_m_a_s_k    specifies the netmask of the  local  net.
  272.        A   return   of    -1  indicates  an  error  in  which  case
  273.        ppccaapp__ggeetteerrrr(()) may be used to display the    error text.
  274.  
  275.        ppccaapp__ccoommppiillee__nnooppccaapp(()) is    similar    to ppccaapp__ccoommppiillee(())  except
  276.        that  instead  of passing a pcap    structure, one passes the
  277.        snaplen and linktype explicitly.     It  is     intended  to  be
  278.        used  for  compiling filters for    direct BPF usage, without
  279.        necessarily having called ppccaapp__ooppeenn(()).    A  return  of  -1
  280.        indicates   an  error;  the  error  text     is  unavailable.
  281.        (ppccaapp__ccoommppiillee__nnooppccaapp(())      is     a     wrapper       around
  282.        ppccaapp__ooppeenn__ddeeaadd(()),  ppccaapp__ccoommppiillee(()),  and    ppccaapp__cclloossee(()); the
  283.        latter three routines can be used directly in order to get
  284.        the error text for a compilation    error.)
  285.  
  286.        ppccaapp__sseettffiilltteerr(())     is used to specify a filter program.  _f_p
  287.        is a pointer to a _b_p_f___p_r_o_g_r_a_m struct, usually  the  result
  288.        of  a  call to ppccaapp__ccoommppiillee(()).  --11 is returned on failure,
  289.        in which    case ppccaapp__ggeetteerrrr(()) may be  used     to  display  the
  290.        error text; 00 is    returned on success.
  291.  
  292.        ppccaapp__ffrreeeeccooddee(())    is  used  to  free  up    allocated  memory
  293.        pointed to by a _b_p_f___p_r_o_g_r_a_m struct generated by    ppccaapp__ccoomm
  294.        ppiillee(())  when  that  BPF    program     is no longer needed, for
  295.        example after it    has been made the filter  program  for    a
  296.        pcap structure by a call    to ppccaapp__sseettffiilltteerr(()).
  297.  
  298.        ppccaapp__ddaattaalliinnkk(())    returns     the  link layer type; link layer
  299.        types it    can return include:
  300.  
  301.  
  302.         DDLLTT__NNUULLLL
  303.          BSD  loopback    encapsulation;    the  link   layer
  304.          header     is  a    4-byte field, in _h_o_s_t byte order,
  305.          containing a PF_ value     from  ssoocckkeett..hh     for  the
  306.          network-layer protocol    of the packet
  307.  
  308.          Note  that ``host byte    order''    is the byte order
  309.          of the    machine    on which  the  packets    are  cap
  310.          tured,     and the PF_ values are    for the    OS of the
  311.          machine on which the packets are captured; if    a
  312.          live  capture is being    done, ``host byte order''
  313.          is the    byte order of the machine  capturing  the
  314.          packets,  and the PF_ values are those    of the OS
  315.          of the    machine    capturing the packets, but  if    a
  316.          ``savefile''  is  being read, the byte    order and
  317.          PF_ values are     _n_o_t  necessarily  those  of  the
  318.          machine reading the capture file.
  319.  
  320.         DDLLTT__EENN1100MMBB
  321.          Ethernet (10Mb, 100Mb,    1000Mb,    and up)
  322.  
  323.         DDLLTT__IIEEEEEE880022
  324.          IEEE 802.5 Token Ring
  325.  
  326.         DDLLTT__AARRCCNNEETT
  327.          ARCNET
  328.  
  329.         DDLLTT__SSLLIIPP
  330.          SLIP; the link    layer header contains, in order:
  331.  
  332.               a     1-byte     flag,    which  is  0  for packets
  333.               received by the machine and 1  for  packets
  334.               sent by the machine;
  335.  
  336.               a     1-byte     field,    the upper 4 bits of which
  337.               indicate the type    of  packet,  as     per  RFC
  338.               1144:
  339.  
  340.                0x40    an    unmodified    IP     datagram
  341.                 (TYPE_IP);
  342.  
  343.                0x70    an uncompressed-TCP  IP     datagram
  344.                 (UNCOMPRESSED_TCP),   with   that
  345.                 byte being the first byte of  the
  346.                 raw  IP     header    on the wire, con
  347.                 taining    the connection number  in
  348.                 the protocol field;
  349.  
  350.                0x80    a   compressed-TCP   IP     datagram
  351.                 (COMPRESSED_TCP), with that  byte
  352.                 being  the first byte of the com
  353.                 pressed    TCP/IP datagram    header;
  354.  
  355.               for UNCOMPRESSED_TCP, the    rest of    the modi
  356.               fied IP header, and for COMPRESSED_TCP, the
  357.               compressed TCP/IP    datagram header;
  358.  
  359.          for a total of    16  bytes;  the     uncompressed  IP
  360.          datagram follows the header
  361.  
  362.         DDLLTT__PPPPPP
  363.          PPP;  if  the    first  2 bytes are 0xff    and 0x03,
  364.          it's PPP in  HDLC-like     framing,  with     the  PPP
  365.          header    following those    two bytes, otherwise it's
  366.          PPP without framing, and the packet begins  with
  367.          the PPP header
  368.  
  369.         DDLLTT__FFDDDDII
  370.          FDDI
  371.  
  372.         DDLLTT__AATTMM__RRFFCC11448833
  373.          RFC  1483  LLC/SNAP-encapsulated ATM; the packet
  374.          begins    with an    IEEE 802.2 LLC header
  375.  
  376.         DDLLTT__RRAAWW
  377.          raw IP; the packet begins with    an IP header
  378.  
  379.         DDLLTT__PPPPPP__SSEERRIIAALL
  380.          PPP in    HDLC-like framing, as per  RFC    1662,  or
  381.          Cisco    PPP  with  HDLC     framing,  as per section
  382.          4.3.1 of RFC 1547; the    first byte will     be  0xFF
  383.          for  PPP  in HDLC-like    framing, and will be 0x0F
  384.          or 0x8F for Cisco PPP with HDLC framing
  385.  
  386.         DDLLTT__PPPPPP__EETTHHEERR
  387.          PPPoE;    the packet begins with a PPPoE header, as
  388.          per RFC 2516
  389.  
  390.         DDLLTT__CC__HHDDLLCC
  391.          Cisco    PPP  with  HDLC     framing,  as per section
  392.          4.3.1 of RFC 1547
  393.  
  394.         DDLLTT__IIEEEEEE880022__1111
  395.          IEEE 802.11 wireless LAN
  396.  
  397.         DDLLTT__LLOOOOPP
  398.          OpenBSD loopback encapsulation; the  link  layer
  399.          header    is a 4-byte field, in _n_e_t_w_o_r_k byte order,
  400.          containing a PF_ value    from  OpenBSD's     ssoocckkeett..hh
  401.          for the network-layer protocol    of the packet
  402.  
  403.          Note  that,  if  a  ``savefile''  is being read,
  404.          those PF_ values are _n_o_t  necessarily    those  of
  405.          the machine reading the capture file.
  406.  
  407.         DDLLTT__LLIINNUUXX__SSLLLL
  408.          Linux    "cooked"  capture encapsulation; the link
  409.          layer header contains,    in order:
  410.  
  411.               a    2-byte "packet    type",    in  network  byte
  412.               order, which is one of:
  413.  
  414.                0    packet was sent    to us by somebody
  415.                 else
  416.  
  417.                1    packet was broadcast by     somebody
  418.                 else
  419.  
  420.                2    packet    was  multicast,     but  not
  421.                 broadcast, by somebody else
  422.  
  423.                3    packet was sent    by somebody  else
  424.                 to somebody else
  425.  
  426.                4    packet was sent    by us
  427.  
  428.               a    2-byte field, in network byte order, con
  429.               taining a    Linux ARPHRD_ value for    the  link
  430.               layer device type;
  431.  
  432.               a    2-byte field, in network byte order, con
  433.               taining  the  length  of    the  link   layer
  434.               address  of the sender of    the packet (which
  435.               could be 0);
  436.  
  437.               an 8-byte    field containing that  number  of
  438.               bytes  of     the  link layer header    (if there
  439.               are more than 8 bytes, only the first 8 are
  440.               present);
  441.  
  442.               a     2-byte    field containing an Ethernet pro
  443.               tocol type, in network byte order, or  con
  444.               taining  1  for Novell 802.3 frames without
  445.               an 802.2 LLC header or 4 for frames  begin
  446.               ning with    an 802.2 LLC header.
  447.  
  448.         DDLLTT__LLTTAALLKK
  449.          Apple    LocalTalk;  the     packet     begins     with  an
  450.          AppleTalk LLAP    header
  451.  
  452.        ppccaapp__ssnnaappsshhoott(()) returns the snapshot length specified when
  453.        ppccaapp__ooppeenn__lliivvee was called.
  454.  
  455.        ppccaapp__iiss__sswwaappppeedd(()) returns true if the current ``savefile''
  456.        uses a different    byte order than    the current system.
  457.  
  458.        ppccaapp__mmaajjoorr__vveerrssiioonn(()) returns the    major number of    the  ver
  459.        sion of the pcap    used to    write the savefile.
  460.  
  461.        ppccaapp__mmiinnoorr__vveerrssiioonn(())  returns the minor number of the ver
  462.        sion of the pcap    used to    write the savefile.
  463.  
  464.        ppccaapp__ffiillee(()) returns the standard    I/O stream of the ``save
  465.        file,''      if    a    ``savefile''    was    opened   with
  466.        ppccaapp__ooppeenn__oofffflliinnee(()), or NULL,  if  a  network  device  was
  467.        opened with ppccaapp__ooppeenn__lliivvee(()).
  468.  
  469.        ppccaapp__ssttaattss(())  returns  0     and fills in a    ppccaapp__ssttaatt struct.
  470.        The values represent packet statistics from the    start  of
  471.        the  run     to the    time of    the call. If there is an error or
  472.        the  underlying    packet    capture     doesn't  support  packet
  473.        statistics,  -1    is  returned  and  the    error text can be
  474.        obtained       with       ppccaapp__ppeerrrroorr(())    or       ppccaapp__ggeetteerrrr(()).
  475.        ppccaapp__ssttaattss(())  is     supported  only on live captures, not on
  476.        ``savefiles''; no statistics are    stored in  ``savefiles'',
  477.        so no statistics    are available when reading from    a ``save
  478.        file''.
  479.  
  480.        ppccaapp__ffiilleennoo(()) returns  the  file     descriptor  number  from
  481.        which  captured    packets    are read, if a network device was
  482.        opened with ppccaapp__ooppeenn__lliivvee(()), or    -1, if a ``savefile'' was
  483.        opened with ppccaapp__ooppeenn__oofffflliinnee(()).
  484.  
  485.        ppccaapp__ppeerrrroorr(())  prints  the  text     of the    last pcap library
  486.        error on    ssttddeerrrr,    prefixed by _p_r_e_f_i_x.
  487.  
  488.        ppccaapp__ggeetteerrrr(()) returns the error    text  pertaining  to  the
  489.        last  pcap  library  error.   NNOOTTEE: the pointer it returns
  490.        will no longer point to a valid error message string after
  491.        the  ppccaapp__tt  passed  to it is closed; you must use or copy
  492.        the string before closing the ppccaapp__tt.
  493.  
  494.        ppccaapp__ssttrreerrrroorr(()) is  provided  in     case  ssttrreerrrroorr(1)  isn't
  495.        available.
  496.  
  497.        ppccaapp__cclloossee(())  closes the    files associated with _p    and deal
  498.        locates resources.
  499.  
  500.        ppccaapp__dduummpp__cclloossee(()) closes    the ``savefile.''
  501.  
  502.  
  503. SSEEEE AALLSSOO
  504.        tcpdump(1), tcpslice(1)
  505.  
  506. AAUUTTHHOORRSS
  507.        The original authors are:
  508.  
  509.        Van Jacobson, Craig Leres and Steven McCanne, all  of  the
  510.        Lawrence    Berkeley National Laboratory, University of Cali
  511.        fornia, Berkeley, CA.
  512.  
  513.        The  current  version  is  available  from  "The      Tcpdump
  514.        Group"'s    Web site at
  515.  
  516.           _h_t_t_p_:_/_/_w_w_w_._t_c_p_d_u_m_p_._o_r_g_/
  517.  
  518. BBUUGGSS
  519.        Please  send problems, bugs, questions, desirable enhance
  520.        ments, etc. to:
  521.  
  522.           tcpdump-workers@tcpdump.org
  523.  
  524.        Please send source code contributions, etc. to:
  525.  
  526.           patches@tcpdump.org
  527.  
  528.  
  529.  
  530.               3 January 2001          PCAP(3)
  531.